From 38b25599d8834ca2cca72ac2f86117b13b22c942 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Fri, 2 Feb 2018 14:58:39 +0100 Subject: [PATCH] texture: Add sanity checks to constructors width, height and GL texture ID may not be 0, so return_if_fail() if they are. --- gdk/gdktexture.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gdk/gdktexture.c b/gdk/gdktexture.c index 69721caa78..a8afe84902 100644 --- a/gdk/gdktexture.c +++ b/gdk/gdktexture.c @@ -319,6 +319,9 @@ gdk_texture_new_for_data (const guchar *data, cairo_surface_t *original, *copy; cairo_t *cr; + g_return_val_if_fail (width > 0, NULL); + g_return_val_if_fail (height > 0, NULL); + original = cairo_image_surface_create_for_data ((guchar *) data, CAIRO_FORMAT_ARGB32, width, height, stride); copy = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height); @@ -353,6 +356,8 @@ gdk_texture_new_for_surface (cairo_surface_t *surface) GdkCairoTexture *texture; g_return_val_if_fail (cairo_surface_get_type (surface) == CAIRO_SURFACE_TYPE_IMAGE, NULL); + g_return_val_if_fail (cairo_image_surface_get_width (surface) > 0, NULL); + g_return_val_if_fail (cairo_image_surface_get_height (surface) > 0, NULL); texture = g_object_new (GDK_TYPE_CAIRO_TEXTURE, "width", cairo_image_surface_get_width (surface), @@ -720,6 +725,9 @@ gdk_texture_new_for_gl (GdkGLContext *context, GdkGLTexture *self; g_return_val_if_fail (GDK_IS_GL_CONTEXT (context), NULL); + g_return_val_if_fail (id != 0, NULL); + g_return_val_if_fail (width > 0, NULL); + g_return_val_if_fail (height > 0, NULL); self = g_object_new (GDK_TYPE_GL_TEXTURE, "width", width, -- 2.30.2